class RanksController < ApplicationController
	def index
		users = User.find(:all)
		rank = Hash.new
		for user in users
		  if user.id!=1
			net_worth = user.cash
			holdings = Ownership.find(	:all,
										:conditions => "user_id = '#{user.id}'")
			for holding in holdings
				dummy, market_value = Ownership.details(holding.stock_id)
				net_worth += holding.quantity * market_value
			end
			rank[user.login] = net_worth
		  end
		end
		@rank = rank.sort {|a,b| a[1]<=>b[1]}
	end
end
